
import { getSafeObj } from '../../utils/utils'
/** 获取app用户信息 */
export function getAPPUserInfo() {
  return new Promise((resolve) => {
    const isMock = false
    if (isMock) {
      resolve({
        // mobile: '18838000395',
        mobile: '18483605763',
        avatar: 'https://img.yzcdn.cn/vant/cat.jpeg',
      })
      return
    }
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    getH5UserInfo()
      .then((res) => {
        const userInfo = getSafeObj(res)
        const isMockMobile = false
        if (isMockMobile) {
          userInfo.mobile = '18838000395'
        }
        resolve(userInfo)
      })
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      .catch((err) => {
        console.error(err)
        resolve({})
      })
  })
}
/** 打开支付 */
export function openAppBuyLink(params) {
  return new Promise((resolve) => {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    openBuyLink(params)
    resolve()
  })
}
/** 打开登录页 */
export function openAppLoginPage() {
  return new Promise((resolve) => {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    openLoginPage().then(() => {
      resolve()
    })
  })
}
/** 关闭页面 */
export function closeAppPage() {
  return new Promise((resolve) => {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    closePage()
    resolve()
  })
}